<?php
/**
 * Celebrio Core
 * 
 * @copyright  Copyright (c) 2011 Celebrio Software
 * @package    Celebrio
 * @subpackage Core
 */
namespace Celebrio\AccessControl;

use Nette\Object;

use KernelModule\AclModule\AclManagement;

use Celebrio\Core\IModuleInit;
use Celebrio\Core\DummyInit;

use Celebrio\AccessControl\AclConstants;

class AclCreater extends DummyInit implements IModuleInit {
    
    private $aclManagement;
    
    public function __construct() {
        $this->aclManagement = new AclManagement();
    }

    /**
     * Installs the module (loads it to the system for the first time).
     * This method should contain all the routines which are executed
     * only once (creating DB tables et cetera).
     */
    public function install(array $configuration) {
        $this->aclManagement->addOneRule("admin", "Kernel:Overview", "default", true, AclConstants::ROOT_USER);

        $this->aclManagement->addOneRule("admin", "Kernel:Modules:ModulesManagement", "default", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Modules:ModulesManagement", "install", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Modules:ModulesManagement", "uninstall", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Modules:ModulesManagement", "select", true, null);

        $this->aclManagement->addOneRule("admin", "Kernel:Modules:DatabaseManagement", "default", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Modules:FileSystemManagement", "default", true, null);
        //$this->aclManagement->addOneRule("admin", "Kernel:Modules:UsersManagement", "default", true, null);
        //$this->aclManagement->addOneRule("admin", "Kernel:Modules:WebtopManagement", "default", true, null);

        $this->aclManagement->addOneRule("admin", "Kernel:Modules:Console", "default", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Modules:Terminal", "default", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Modules:GoogleApi", "default", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Modules:GoogleApi", "access", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Modules:GoogleApi", "authorized", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Modules:Picasa", "default", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Modules:Picasa", "access", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Modules:Picasa", "authorized", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Modules:Picasa", "test", true, null);

        $this->aclManagement->addOneRule("admin", "Kernel:Logs:Overview", "default", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Logs:Error", "default", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Logs:Error", "delete", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Logs:Error", "fsProblem", true, null);

        $this->aclManagement->addOneRule("admin", "Kernel:Logs:Php:Process", "default", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Logs:Php:Display", "default", true, null);
        // no link to :Kernel:Logs:Php:Display:check
        // $this->aclManagement->addOneRule("admin", "Kernel:Logs:Php:Display", "check", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Logs:Php:Detail", "default", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Logs:Php:Detail", "debuggerRed", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:UsersOverview", "default", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Logs:Acl:Display", "default", true, null);

        $this->aclManagement->addOneRule("admin", "Kernel:Users:Overview", "default", true, null);
        
        $this->aclManagement->addOneRule("admin", "Kernel:Users:Users", "default", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Users:Users", "add", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Users:Users", "delete", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Users:Users", "edit", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Users:Users", "access", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Users:Users", "hooks", true, null);

        $this->aclManagement->addOneRule("admin", "Kernel:Users:Roles", "default", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Users:Roles", "add", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Users:Roles", "delete", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Users:Roles", "edit", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Users:Roles", "users", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Users:Roles", "access", true, null);

        $this->aclManagement->addOneRule("admin", "Kernel:Acl:Overview", "default", true, null);

        $this->aclManagement->addOneRule("admin", "Kernel:Acl:Resources", "default", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Acl:Resources", "add", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Acl:Resources", "delete", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Acl:Resources", "edit", true, null);

        $this->aclManagement->addOneRule("admin", "Kernel:Acl:Privileges", "default", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Acl:Privileges", "add", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Acl:Privileges", "delete", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Acl:Privileges", "edit", true, null);

        $this->aclManagement->addOneRule("admin", "Kernel:Acl:Permissions", "default", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Acl:Permissions", "add", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Acl:Permissions", "delete", true, null);
        $this->aclManagement->addOneRule("admin", "Kernel:Acl:Permissions", "edit", true, null);
        $this->aclManagement->addOneRule("admin", "Webtop:Default", "default", true, null);
    }

}